<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>校园破冰交友与失物招领平台-失物招领</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" type="text/css" href="../assets/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../assets/fonts/line-icons.css">
    <link rel="stylesheet" type="text/css" href="../assets/css/main.css">
    <link rel="stylesheet" type="text/css" href="../assets/css/responsive.css">
</head>
<body>
<div class="container-fluid">
	<div class="breadcrumb-wrapper row">
		<div class="col-12 col-lg-3 col-md-6">
			<h4 class="page-title">发布失物招领</h4>
		</div>
		<div class="col-12 col-lg-9 col-md-6">
			<ol class="breadcrumb float-right">
				<li class="active">失物招领管理</li>
				<li class="active"> / 发布失物招领</li>
			</ol>
		</div>
	</div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-12 grid-margin">
            <div class="card">
                <div class="card-body">
                    <form class="form-sample">
                        <p class="card-description">失物信息</p>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">标题</label>
                                    <div class="col-sm-9">
                                        <input id="title" type="text" class="form-control">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">介绍</label>
                                    <div class="col-sm-9">
                                        <textarea id="introduce" class="form-control" rows="5"></textarea>
                                    </div>
                                </div>
								<div class="form-group row">
								    <label class="col-sm-3 col-form-label">失物图片</label>
								    <div class="col-sm-9">
								         <input type="file" accept="image/*" id="file"/>
								    </div>
								</div>
                            </div>
                        </div>
                        <div class="text-center">
                            <input class="btn btn-common mr-3" id="sureButton" value="确认"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/js/jquery-min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script>
    $(function () {
        var ctx = window.parent.ctx;

        $("#sureButton").click(function () {
            var formData = new FormData();
            formData.append("file",$("#file")[0].files[0]);
            formData.append("title",$("#title").val());
            formData.append("introduce",$("#introduce").val());
            $.ajax({
                url: ctx+"/lostInfo/insert",
                type: "POST",
				xhrFields: {
				    withCredentials: true
				},
                data: formData,
                processData: false,
                contentType: false,
                success: function (data) {
                    alert(data);
					window.location.reload();
                }
            })
        })
    })
</script>
</body>
</html>